package com.kapukapu.gateway.config;

import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.BlockRequestHandler;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.ServerResponse;

import static org.springframework.web.reactive.function.BodyInserters.fromValue;

/**
 * @author: sivan
 * @date: 2019/12/24
 * @email: zifanuu@gmail.com
 */
@Configuration
public class SentinelConfiguration {
  @Bean
  public BlockRequestHandler blockRequestHandler() {
    return (exchange, t) -> ServerResponse.status(444)
				.body(fromValue("SCS Sentinel block"));
  }
}
